#include "StdAfx.h"
#include "SubStructure.h"
#include "BulletMove.h"
#include "Bullet.h"

Bullet::Bullet(int nId)
{
	id = nId;
	Grazed = false;
}

Bullet::~Bullet()
{
	UINT i = 0;
	UINT j = 0;
	for(; i < moveVec.size();++i)
	{
		for(j = 0; j < moveVec[i].size(); ++j)
		{
			if(moveVec[i][j] != NULL)
			{
				delete moveVec[i][j];
			}
		}
		moveVec[i].clear();
	}
}

void Bullet::SetBound(BoundBoxVec nbound)
{
	bound = nbound;
}

void Bullet::SetAni(AniVec2 nAni)
{
	_pAni = nAni;
	nowAni = *_pAni[0][0];
}

void Bullet::SetMove(Move_Vec2 nVec)
{
	moveVec = nVec;
	nowMove = (*moveVec[0][0]);
}

void Bullet::SetPos(D3DXVECTOR2 newPos)
{
	pos = newPos;
}

void Bullet::SetAlgorithm(BulletMove* nAlgorithm)
{
	moveAlgorithm = nAlgorithm;
}

void Bullet::SetRandID(DWORD nid)
{
	randid = nid;
}

void Bullet::SetGrazed()
{
	Grazed = true;
}

bool Bullet::GetGrazed()
{
	return Grazed;
}

BoundBoxVec Bullet::GetBound()
{
	return bound;
}

D3DXVECTOR2 Bullet::GetPos()
{
	return pos;
}
D3DXVECTOR2 Bullet::GetCPos()
{
	D3DXVECTOR2 temp;
	temp.x = (nowAni.Source.bottom - nowAni.Source.top)/2;
	temp.y = temp.x;
	temp += pos;
	return temp;
}